﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class cms_Deployment : System.Web.UI.Page
{
    private int TypeId = 0;
    private DBClass db = new DBClass();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        ddlType.DataSource = db.GetAllType();
        ddlType.DataBind();
        ddlType.Items.Insert(0, new ListItem("Select", "0"));
        LoadGridview();
    }

    private void LoadGridview()
    {
        grvDeployment.DataSource = db.GetListDeploymentByTypeId(TypeId);
        grvDeployment.DataBind();
    }

    protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
    {
        Int32.TryParse(ddlType.SelectedValue, out TypeId);
        LoadGridview();
    }
    protected void grvDevelopment_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            db.DeleteDeployment(Convert.ToInt32(e.CommandArgument));
        }
        Response.Redirect("Deployment.aspx");
    }
}